package cn.yunhe.action;

import cn.yunhe.service.EmpService;
import com.alibaba.fastjson.JSON;
import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.ParentPackage;
import org.apache.struts2.convention.annotation.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import java.util.HashMap;
import java.util.Map;

@Controller
@Scope("prototype")
@ParentPackage("json-default")
public class EmpManagerAction extends ActionUtil {
    private Map<String,Object> empMap = new HashMap<String, Object>();
    private int pageIndex;

    @Autowired
    @Qualifier("empService")
    private EmpService empService;

    @Action(value = "emp_getEmpInfo",results = {
            @Result(type = "json",params = {"root","empMap"})
    })
    public String getEmpInfo() {
        empMap = empService.getEmpInfo(pageIndex);
        return SUCCESS;
    }

    public EmpService getEmpService() {
        return empService;
    }

    public void setEmpService(EmpService empService) {
        this.empService = empService;
    }

    public Map<String, Object> getEmpMap() {
        return empMap;
    }

    public void setEmpMap(Map<String, Object> empMap) {
        this.empMap = empMap;
    }

    public int getPageIndex() {
        return pageIndex;
    }

    public void setPageIndex(int pageIndex) {
        this.pageIndex = pageIndex;
    }
}
